import { createRouter, createWebHashHistory } from 'vue-router'
const Layout = () => import('@/views/Layout')
const Home = () => import('@/views/Home/index')
const TopCategory = () => import('@/views/Category/index')
const SubCategory = () => import('@/views/Category/Sub')
const Goods = () => import('@/views/Goods/index')
const Login = () => import('@/views/Login')

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: Home },
      { path: '/category/:id', component: TopCategory },
      { path: '/category/sub/:id', component: SubCategory },
      {
        path: '/goods/:id',
        component: Goods
      }
    ]
  },
  { path: '/login', component: Login },
  {
    path: '/play',
    component: () => import('@/views/Playground')
  }
]

// 创建路由实例
const router = createRouter({
  // 使用hash方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则,写法和之前一样
  routes
})

export default router
